package cn.ycc1.boot3rabbitmq.controller;

import cn.ycc1.boot3rabbitmq.service.VO.UserVO;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ycc
 * @date 2024/10/28
 */
@RestController
public class TestController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/test")
    public String test() {
        UserVO userVO = new UserVO();
        userVO.setId(1L);
        userVO.setUsername("张三");
        // rabbitTemplate.convertAndSend("myExchange", "routingKey", "Hello, RabbitMQ!");
        rabbitTemplate.convertAndSend("myExchange", "testRoutingKey", userVO);
        return "hello rabbitmq";
    }
}
